<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<table class="table">
    <tr>
        <td>
            <a href="/after/show/show">返回展示界面</a>
        </td>
        <td>
            <form action="http://www.admin.com/home/home/recycling" method="get">
                <input type="text" name="word">
                <input type="submit" value="搜索">
            </form>
        </td>
    </tr>

    <tr>
        <th>
            <a href="#" onclick="fu()">选定</a>
            <a href="#" class="delall" onclick="delall()">批量删除</a>
        </th>
        <th>ID</th>
        <th>订单编号</th>
        <th>下单日期</th>
        <th>收货人</th>
        <th>支付方式</th>
        <th>总金额</th>
        <th>订单状态</th>
        <th>操作</th>
    </tr>
    {foreach $data as $k=>$v}
    <tr class="success">
        <td><input type="checkbox" value="{$v.id}" name="id"></td>
        <td>{$v.id}</td>
        <td>{$v.o_order_id}</td>
        <td>{$v.o_order_time}</td>
        <td>{$v.o_consignee}</td>
        <td>{$v.o_mode}</td>
        <td>{$v.o_amount}</td>
        <td>
            {if $v.o_state==1}
            <a href="#">
                未付款
            </a>
            {/if}
            {if $v.o_state==2}
            <a href="#">
                已付款
            </a>
            {/if}
            {if $v.o_state==3}
            <a class="state{$v.id}" href="#">
                未发货
            </a>
            {/if}
            {if $v.o_state==4}
            <a state{$v.id} href="#">
                已发货
            </a>
            {/if}
        </td>
        <td>
            <a href="/after/after/delete?id={$v.id}">彻底删除</a>
            &emsp;
            <a href="/after/after/restore?id={$v.id}">恢复</a>
        </td>
    </tr>
    {/foreach}
</table>
{$data->render()}

<script src="https://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.2.min.js">
</script>
<script>
    function fu() {

        $(":checkbox").each(function (k, v) {
            v['checked'] = !v['checked']
        })
    }

    //批量删除
    function delall() {
        var token = localStorage.getItem('token');
        var arr = [];
        $(':checkbox:checked').each(function (i, v) {
            //向数组中添加元素
            arr.push($(v).val());
        })
        // 书写ajax
        $.ajax({
            'url': "http://www.admin.com/home/home/checkDel?id=" + arr + '&token=' + token,
            'type': 'GET',
            'dataType': 'JSON',
            success: function (e) {
                console.log(e)
                $(':checkbox :checked').each(function (k, v) {
                    $(v).parents('tr').remove()
                })
            }
        })
    }


</script>
